package org.text2diagram.ddl.converter;

import java.util.ArrayList;

import org.text2diagram.ddl.domain.Block;
import org.text2diagram.ddl.domain.Container;
import org.text2diagram.ddl.domain.Group;
import org.text2diagram.ddl.domain.Layout;
import org.text2diagram.ddl.domain.Link;

public class DiagramDescription {

	private ArrayList<Block> blockList = new ArrayList<Block>();
	private ArrayList<Link> linkList = new ArrayList<Link>();
	private ArrayList<Group> groupList = new ArrayList<Group>();
	private ArrayList<Container> containerList = new ArrayList<Container>();
	private Layout layout;	
	
	private ArrayList<ConverterException> parsingErrors;
	
	public DiagramDescription() {
	}
	
	public DiagramDescription(ArrayList<Block> blockList,
			ArrayList<Link> linkList, ArrayList<Group> groupList,
			ArrayList<Container> containerList, Layout layout) {
		super();
		this.blockList = blockList;
		this.linkList = linkList;
		this.groupList = groupList;
		this.containerList = containerList;
		this.layout = layout;
	}
	
	@Override
	public String toString() {
		return "Blocks: {\n" + 
				listAsString(blockList, "\t") +	"\n" +			
			"},\n" +
			"Links: {\n" +
				listAsString(linkList, "\t") + "\n" +	
			"},\n" +
			"Groups: {\n" +
				listAsString(groupList, "\t") + "\n" +	
			"},\n" +
			"Containers: {\n" +
				listAsString(containerList, "\t") + "\n" +	
			"},\n" +
			"Layout: " + layout;
	}
	
	private String listAsString(ArrayList<?> list, String prefix) {
		if (list == null || list.size() == 0)
			return "";
		String result = "";
		for (Object item : list)
			result = result + prefix + item + ",\n";
		if (result.length() > 0)
			return result.substring(0, result.length() - 2);
		return "";
	}

	public ArrayList<Block> getBlockList() {
		return blockList;
	}
	
	public void setBlockList(ArrayList<Block> blockList) {
		this.blockList = blockList;
	}
	
	public ArrayList<Link> getLinkList() {
		return linkList;
	}
	
	public void setLinkList(ArrayList<Link> linkList) {
		this.linkList = linkList;
	}
	
	public Layout getLayout() {
		return layout;
	}
	
	public void setLayout(Layout layout) {
		this.layout = layout;
	}

	public void setGroupList(ArrayList<Group> groupList) {
		this.groupList = groupList;
	}

	public ArrayList<Group> getGroupList() {
		return groupList;
	}

	public void setContainerList(ArrayList<Container> containerList) {
		this.containerList = containerList;
	}

	public ArrayList<Container> getContainerList() {
		return containerList;
	}

	public void setParsingErrors(ArrayList<ConverterException> parsingErrors) {
		this.parsingErrors = parsingErrors;
	}

	public ArrayList<ConverterException> getParsingErrors() {
		return parsingErrors;
	}

	
}
